package com.example.basic.utils;

import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtils {

    public static void main(String[] args) {
        System.out.println(timestamp2DateStr("1631863207"));
    }

    public static String timestamp2DateStr(String timestamp) {
        if (timestamp.length() == 10) {
            timestamp = timestamp + "000";
        }
        String format = "yyyy-MM-dd";
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        return sdf.format(new Date(Long.valueOf(timestamp)));
    }

}
